package com.cy.pj.notice.service.impl;

import com.cy.pj.notice.dao.SysNoticeDao;
import com.cy.pj.notice.pojo.SysNotice;
import com.cy.pj.notice.service.SysNoticeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;
//公告业务的具体实现
// 1 核心业务  （调用数据方法操作数据。。。。）
// 2 拓展业务（日志记录，权限控制，事务控制，缓存，。。。） 3
@Service

public class SysNoticeServiceImpl implements SysNoticeService {
    //初始化日志对象（org.slf4j.*）
    private static final Logger Log=
           LoggerFactory.getLogger(SysNoticeServiceImpl.class);
    //has a
   // @Autowired
    private SysNoticeDao sysNoticeDao;
    //通过构造方法直接进行DI操作
    public SysNoticeServiceImpl (SysNoticeDao sysNoticeDao){
        this.sysNoticeDao=sysNoticeDao;
    }
    @Override
    public List<SysNotice> findNotices(SysNotice sysNotice) {
       long t1=System.currentTimeMillis();
        Log.info("method start {}",t1);//{}代表占符
       List <SysNotice> list = sysNoticeDao.selectNotices(sysNotice);
        long t2=System.currentTimeMillis();
        Log.info("method start {}",t2);
        return list;
    }

    @Override
    public int saveNotice(SysNotice sysNotice) {
       int rows= sysNoticeDao.insertNotice(sysNotice);
        return rows;
    }

    @Override
    public SysNotice findById(Long id) {
       SysNotice notice= sysNoticeDao.findById(id);
        return notice;
    }

    @Override
    public int updateNotice(SysNotice sysNotice) {
       int rows = sysNoticeDao.updateNotice(sysNotice);
        return rows;
    }

    @Override
    public int deleteById(Long... id) {
      int rows=  sysNoticeDao.deleteById(id);
        return rows;
    }
}
